package com.cfuture08.eweb4j.orm.config.log;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;

import com.cfuture08.eweb4j.config.log.Logger;
import com.cfuture08.util.StringUtil;

public class ORMLogger implements Logger {
	private String filePath;

	public ORMLogger(String filePath) {
		this.filePath = filePath;
	}

	@Override
	public void write(String info) {
		try {
			if (this.filePath != null) {
				File file = new File(this.filePath);
				if (!file.exists()) {
					file.createNewFile();
				}

				BufferedWriter bw = new BufferedWriter(new FileWriter(file,true));
				StringBuilder sb = new StringBuilder();
				sb.append(StringUtil.getNowTime());
				sb.append(" -ORM -INFO : ");
				sb.append(info);
				bw.newLine();
				bw.write(sb.toString());
				bw.close();
			}
		} catch (Exception e) {

		}
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

}
